import java.util.Scanner;

public class MinxueTwo {
    public static void main(String[] args) {
        orderTwo();
    }

    public static void orderTwo() {
        Scanner scanner = new Scanner(System.in);
        //营业额
        double total = 0;
        //单个用户总金额
        double orderAmount = 0;
        int quite = 0;

        System.out.println("===========================");
        System.out.println("||       某店铺点餐系统     ||");
        System.out.println("===========================");
        while (quite != 9){
            System.out.println("请输入你要选择的餐点（1、橙汁 2、咖啡 3、面包 0、结算 9、退出系统）");
            int selectedMenu = scanner.nextInt();
            switch (selectedMenu) {
                case 1:
                case 2:
                    //咖啡
                    orderAmount = computeAmountByCup(scanner, selectedMenu, orderAmount);
                    break;
                case 3:
                    //面包
                    orderAmount += 13;
                    break;
                case 0:
                    //结算
                    //算出总金额 把orderAmount的值重置为0
                    System.out.println("结算:" + orderAmount);
                    total += orderAmount;
                    System.out.println("今天总营业额:" + total);
                    System.out.printf("本站占当天营业额比例为：%.2f %%", (orderAmount / total) * 100);
                    orderAmount = 0;
                    break;
                case 9:
                    quite = 9;
                    System.out.println("系统正在退出，一天的牛马生活终于结束了！");
                    break;
                default:
                    System.out.println("没有这个操作");
            }

        }
    }

    public static void orderOne() {
        Scanner scanner = new Scanner(System.in);
        //营业额
        double total = 0;
        //单个用户总金额
        double orderAmount = 0;
        int quite = 0;

        System.out.println("===========================");
        System.out.println("||       某店铺点餐系统     ||");
        System.out.println("===========================");
        do{
            System.out.println("请输入你要选择的餐点（1、橙汁 2、咖啡 3、面包 0、结算 9、退出系统）");
            int selectedMenu = scanner.nextInt();
            switch (selectedMenu) {
                case 1:
                case 2:
                    //咖啡
                    orderAmount = computeAmountByCup(scanner, selectedMenu, orderAmount);
                    break;
                case 3:
                    //面包
                    orderAmount += 13;
                    break;
                case 0:
                    //结算
                    //算出总金额 把orderAmount的值重置为0
                    System.out.println(String.format("结算：%.2f", orderAmount));
//                    System.out.println("结算:" + orderAmount);
                    total += orderAmount;
                    System.out.println("今天总营业额:" + total);
                    orderAmount = 0;
                    break;
                case 9:
                    quite = 9;
                    System.out.println("系统正在退出，一天的牛马生活终于结束了！");
                    break;
                default:
                    System.out.println("没有这个操作");
            }

        }while (quite != 9);
    }

    //根据饮品的杯型计算价格
    public static double computeAmountByCup(Scanner scanner, int selected, double orderAmount) {
        double originMiddle = 10.91;
        double originBig = 12.55;
        double originSuper = 15.64;

        double coffeeMiddle = 12;
        double coffeeBig = 14.5;
        double coffeeSuper = 18.7;
        System.out.println("请选择大小：1、中杯 2、大杯 3、超大杯");
        int cupType = scanner.nextInt();
        switch (selected) {
            case 1:
                switch (cupType) {
                    case 1:
                        orderAmount += originMiddle;
                        break;
                    case 2:
                        orderAmount += originBig;
                        break;
                    case 3:
                        orderAmount += originSuper;
                        break;
                }
                break;
            case 2:
                switch (cupType) {
                    case 1:
                        orderAmount += coffeeMiddle;
                        break;
                    case 2:
                        orderAmount += coffeeBig;
                        break;
                    case 3:
                        orderAmount += coffeeSuper;
                        break;
                }
                break;
        }

        return orderAmount;
    }
}
